﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>table 组件综合演示 - Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//unpkg.com/layui@2.10.1/dist/css/layui.css" rel="stylesheet">
    <style>
        /* 修改编辑按钮颜色 */
        .layui-btn.layui-btn-xs[lay-event="edit"] {
            background-color: orange;
            color: white;
        }
    </style>
</head>

<body>
    <div style="padding: 16px;">
        <!-- 添加查询条件 -->
        <div style="margin-bottom: 10px;">
            <input type="text" id="bomCode" placeholder="请输入Bom编号" class="layui-input" style="width: 200px; display: inline-block;">
            <input type="text" id="productName" placeholder="请输入成品名称" class="layui-input" style="width: 200px; display: inline-block;">
            <input type="text" id="bomVersion" placeholder="请输入版本" class="layui-input" style="width: 200px; display: inline-block;">
            <button class="layui-btn" id="searchBtn">查询</button>
        </div>
        <!-- 添加添加权限按钮 -->
        <button class="layui-btn" id="addPermissionBtn">添加Bom</button>
        <b><a style="color:red" href="http://localhost:8075/webroot/decision/view/duchamp?viewlet=%25E6%2598%258E%25E7%25BB%2586%25E8%25A1%25A8%252F7%25E5%25A4%25A9%25E5%258F%2591%25E8%25B4%25A7%25E6%2598%258E%25E7%25BB%2586%25E8%25A1%25A8.fvs&page_number=1" target="_blank">7天发货明细表(帆软)</a></b>&nbsp;&nbsp;
        <b> <a style="color:red" href="http://localhost:8075/webroot/decision/view/duchamp?viewlet=%25E6%2598%258E%25E7%25BB%2586%25E8%25A1%25A8%252F%25E9%2594%2580%25E5%2594%25AE%25E8%25AE%25A2%25E5%258D%2595%25E6%2598%258E%25E7%25BB%2586%25E8%25A1%25A8.fvs&page_number=1" target="_blank">销售订单明细表(帆软)</a></b>
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
    <!-- 新增的最后一列操作按钮模板 -->
    <script type="text/html" id="operateTemplate">
        <a class="layui-btn layui-btn-xs" lay-event="detail">查看详细</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    </script>
    <script src="//unpkg.com/layui@2.10.1/dist/layui.js"></script>
    <script>
        layui.use(['table', 'dropdown', 'layer', 'form', 'jquery'], function () {
            var table = layui.table;
            var dropdown = layui.dropdown;
            var layer = layui.layer;
            var form = layui.form;
            var $ = layui.jquery;

            // 表格渲染配置
            table.render({
                elem: '#test',
                //url: 'http://localhost:5234/api/WorkOrder/GetBomAll',
                url: "@ViewBag.BaseUrl/T7/WorkOrder/GetBomAll",
                toolbar: '#toolbarDemo',
                defaultToolbar: ['filter', 'exports', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips',
                    onClick: function () {
                        layer.alert('自定义工具栏图标按钮');
                    }
                }],
                height: 'full-35',
                css: ['.layui-table-tool-temp{padding-right: 145px;}'].join(''),
                cellMinWidth: 80,
                totalRow: true,
                page: true,
                cols: [[
                    { type: 'checkbox', fixed: 'left' },
                    { field: 'bomCode', title: 'BOM编号' },
                    { field: 'defaultBom', title: '默认BOM' },
                    { field: 'productType', title: '成品类型' },
                    { field: 'productName', title: '成品名称' },
                    { field: 'productionNum', title: '日产量' },
                    { field: 'bomTheme', title: 'BOM主题' },
                    { field: 'bomVersion', title: '版本' },
                    { field: 'estimatedCost', title: '预估成本' },
                    { field: 'inventory', title: '当前库存' },
                    { field: 'remarks', title: '备注' },

                    { title: '操作', toolbar: '#operateTemplate', width: 150 }
                ]],
                error: function (res, msg) {
                    console.error('表格加载失败:', res, msg);
                }
            });

            // 为添加Bom按钮绑定点击事件
            $('#addPermissionBtn').on('click', function () {
                // 跳转到指定界面
                window.location.href = '/WorkOrder/AddBOM';
            });

            // 监听工具条事件
            table.on('tool(test)', function (obj) {
                var data = obj.data;
                if (obj.event === 'detail') {
                    localStorage.setItem('BomCode', data.bomCode);
                    //alert(data.bomCode)
                    // 跳转到详细信息页面，并传递 BOM 编号
                    window.location.href = `/WorkOrder/GetBOMInfo?bomCode`;
                } else if (obj.event === 'edit') {
                    localStorage.setItem('BomCode', data.bomCode);
                    //alert(data.bomCode)
                    window.location.href = `/WorkOrder/UpdateBom?bomCode`;
                    // 这里可以添加修改操作的逻辑
                }
            });
        });
    </script>
</body>

</html>    